<?php
/**
 * @since      Version 0.1
 * @filesource
 * Description of HYD_Province_City
 * @author zch
 */
class HYD_Province_City {

    private $_ci = null;
    private $_data = array();
    
    public function __construct() {
        //initialize the ci instance
        $this->_ci = &get_instance();
        $this->initialize();
    }

    /**
     * 初始化
     * @param array $config
     */
    private function initialize() {
        //加载module模型
        $this->_ci->load->model('province_city_model');
        $province_rows = $this->_ci->province_city_model->get_select_province();
        $this->_data['province'] = array();
        $this->_data['province'] = $province_rows;
    }

    /**
     * 生成下拉列表数据-省
     * @return array
     */
    public function build_province_select() {
        $result = array();
        $result = $this->_data['province'];
        return $result;
    }
    
    /**
     * 生成下拉列表数据-城市
     * @return array
     */
    public function build_city_select($provinceid = NULL) {
        $result = array();
        if(!is_null($provinceid)){
            $result = $this->_ci->province_city_model->get_select_city($provinceid);
        }
        return $result;
    }
    
    public function get_province_name($provinceid = NULL) {
        $result = array();
        if(!is_null($provinceid)){
            $result = $this->_ci->province_city_model->get_province_arr($provinceid);
        }
        return $result['name'];
    }
    
    public function get_city_name($cityid = NULL) {
        $result = array();
        if(!is_null($cityid)){
            $result = $this->_ci->province_city_model->get_city_arr($cityid);
        }
        return $result['name'];
    }
}
?>
